/* Vecmath.

   Copyright (C) 2001, 2002, 2003 Stefan Maierhofer.

   Written by Stefan Maierhofer <sm@cg.tuwien.ac.at>

   This file is part of Vecmath.

   Vecmath is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   Vecmath is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with Vecmath; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */

using System;

namespace Vecmath
{

    /// <summary>
    /// Rot2D.
    /// </summary>
    public struct Rot2D
    {

        public static Rot2D Identity = new Rot2D(0);

        public Rot2D(double radians)
        {
            r = radians;
            cos = Math.Cos(radians);
            sin = Math.Sin(radians);
        }

        public Trafo2D ToTrafo2D()
        {
            return new Trafo2D(
                cos, sin, 0,
                -sin, cos, 0,
                0, 0, 1
                );
        }

        public static implicit operator Trafo2D(Rot2D r)
        {
            return r.ToTrafo2D();
        }

        public static Vec2D operator*(Vec2D v, Rot2D r)
        {
            return v * r.ToTrafo2D();
        }

        public static Pnt2D operator*(Pnt2D p, Rot2D r)
        {
            return p * r.ToTrafo2D();
        }

        public static Trafo2D operator*(Shift2D t, Rot2D r)
        {
            return t.ToTrafo2D() * r.ToTrafo2D();
        }

        public static Trafo2D operator*(Scale2D t, Rot2D r)
        {
            return t.ToTrafo2D() * r.ToTrafo2D();
        }

        private double r;
        private double cos;
        private double sin;

    }

}
